 <link href="<?= STATICURL; ?>css/bootstrap.min.css" rel="stylesheet" />
    <link id="bootstrap-rtl-link" href="" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/font-awesome.min.css" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/weather-icons.min.css" rel="stylesheet" />
    <!--Fonts-->
    <link href="http://fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300" rel="stylesheet" type="text/css">
    <!--Beyond styles-->
    <link id="beyond-link" href="<?= STATICURL; ?>css/beyond.min.css" rel="stylesheet" type="text/css" />
    <link href="<?= STATICURL; ?>css/demo.min.css" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/typicons.min.css" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/animate.min.css" rel="stylesheet" />
    <link id="skin-link" href="" rel="stylesheet" type="text/css" />
    <div class="page-content">
        <div class="page-body">
            <div id="horizontal-form">
                    <form class="form-horizontal" role="form">
                        <div class="row">
                            <div class="col-md-7">
                                <select class="js_parentCat">
                                    <option value="0">-----顶级分类----</option>
                                    <?php foreach($cat_list as $k=>$v):?>                           
                                        <?php if($v['p_level']):?>
                                        <option p_level="<?php echo $v['p_level'];?>"   value="<?=$v['cat_id']?>">
                                            <?php for($i=0;$i<$v['p_level'];$i++){echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";}?><?=$v['cat_name']?>
                                        </option>
                                        <?php else:?>
                                            <option p_level="<?php echo $v['p_level'];?>"   style="font-weight:bold;" value="<?=$v['cat_id']?>">
                                                <?=$v['cat_name']?>
                                            </option>                                                                   
                                        <?php endif;?>
                                                                                
                                    </option>
                                    <?php endforeach;?>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-7">
                                <input class="form-control js_name" type="text" placeholder="请输入分类名称">
                                <div class="horizontal-space"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-7">
                                <input placeholder="排序 默认0" class="form-control js_order" type="text" value="0" />
                                <div class="horizontal-space"></div>
                            </div>
                        </div>
                        <div class="row js_category_cover" style="display: none;float: left;">
                            <div class="col-md-7">
                                <div class="recent-posts" style="float: left">
                                    <li class="cp_photo_con" style="list-style-type:none;">
                                        <p ><span  id="J_morepic_upload"></span></p>
                                    </li>
                                </div>
                            </div>
                        </div>
                        <div class="widget-content" style="float: right">
                            <ul class="thumbnails picList">
                           
                            </ul>
                        </div>
                        <div class="horizontal-space"></div>
                        <div style="clear:both;">
                            <span id="js_submit" class="btn btn-default">提交</span>
                        </div>
                    </form>
                </div>
        </div>
        <input type="hidden" id="idpalce" value="<?php echo $AdInfo['id']?>" />
<script src="<?php echo STATICURL; ?>js/jquery-2.0.3.min.js"></script>
<script src="<?php echo STATICURL; ?>js/bootstrap.min.js"></script>
<script src="<?php echo STATICURL; ?>layer/layer.js"></script>
<script src="<?php echo STATICURL; ?>js/swfupload.js"></script>
<script src="<?php echo STATICURL; ?>js/swfupload.queue.js"></script>
<script src="<?php echo STATICURL; ?>js/fileprogress.js"></script>
<script src="<?php echo STATICURL; ?>js/handlers.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>

<script>
    $(document).ready(function(){
        
        $(".js_order").bind({
                keyup:function(){
                     var txt = $('.js_order').val();
                     var reg = /^[\d]+$/;
                     if(!reg.test(txt) ){
                            $(this).val(0);
                     }
                },
                focus:function(){
                    if ($(this).val() == 0){
                        $(this).val('');
                    }
                },
                blur:function(){
                    if ($(this).val() == ''){
                        $(this).val(0);
                    }
                }
        });        
        $(".js_parentCat").on("change",function(){

            var level1 = $(this).find("option:selected").attr("p_level");
            if(level1 == 3){
                layer.msg("分类已超限，最多可间4级分类");
                $(".js_parentCat").find("option:first").attr("selected",true); 
                // $(".js_parentCat option:first").attr("selected",true);
            }
            if((parseInt(level1)+1) == 2){
                $(".js_category_cover").css("display","block");
                $("#layui-layer-iframe1").css("height","300px");
            }else{
                $(".js_category_cover").css("display","none");
                $("#layui-layer-iframe1").css("height","205px");
            }
        });

        $("#js_submit").click(function(){
            if ($(".js_name").val() == ""){
                layer.msg("请输入分类名称");
                $(".js_name").focus();
                return;
            }
            var next_level = parseInt($(".js_parentCat").find("option:selected").attr("p_level"))+1;
            if(next_level == 4){
                layer.msg("此分类不可建子分类，请选择其他分类");
                return false;
            }
            var cover = $(".imgurl").attr("src"); 
            if(cover == undefined){
                var cover = ""; 
            }
            $.post("/luckydog/category/do_add", {next_level:next_level,cover:cover,cat_name:$(".js_name").val(),parent_id:$(".js_parentCat").val(),sort_order:$(".js_order").val()}, function(data) {
                console.log(data);
                if (data.status) {
                    layer.msg(data.message);
                    window.parent.location.reload();
                }else{
                    layer.msg(data.message);
                }
            }, "json");
        });     
    });


    $(function(){
        var settings = {
            flash_url : "<?php echo STATICURL; ?>js/swfupload.swf",
            upload_url: "<?=BASEURL?>luckydog/ad/upload_cover.json",
            post_params: {"is_more" : "yes"},
            file_size_limit : "1 MB",
            file_types : "*.jpg;*.gif;*.jpeg;*.png;",
            file_upload_limit : 100,
            file_queue_limit : 100,
            custom_settings : {
                progressTarget : "fsUploadProgress",
                cancelButtonId : "btnCancel"
            },
            debug : false,
            // Button settings
            button_width : "114",
            button_height : "32",
            button_placeholder_id : "J_morepic_upload",
            button_text_style : ".theFont { font-size: 16;}",
            button_cursor:-2,
            button_window_mode:"TRANSPARENT",
            button_action:-100,//-110多图片上传，-100但图片上传，-120文件上传
            button_image_url : "<?php echo STATICURL; ?>img/banner_upload_place.png",

            file_queued_handler : fileQueued,
            file_queue_error_handler : fileQueueError,
            file_dialog_complete_handler : fileDialogComplete,
            upload_start_handler : banner_uploadStart,
            upload_progress_handler : uploadProgress,
            upload_error_handler : uploadError,
            upload_success_handler : banner_upload_Success,
            upload_complete_handler : uploadComplete
        };
        swfu = new SWFUpload(settings);
    }())
</script>


